Kinetis SDK Demo Applications User Guide  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
playsound.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 #ifndef __PLAYSOUND_H__
31 #define __PLAYSOUND_H__
32 
33 #include <stdint.h>
34 #include "fsl_soundcard.h"
35 #include "fsl_sgtl5000_driver.h"
36 
37 
38 /*******************************************************************************
39  * Defination
40  ******************************************************************************/
42 #define WAVE_FILE_HEADER_SIZE (0x2C)
43 typedef struct wave_header
45 {
46  uint8_t riff[4];
47  uint32_t size;
48  uint8_t wave_flag[4];
49  uint8_t fmt[4];
50  uint32_t fmt_len;
51  uint16_t tag;
52  uint16_t channels;
53  uint32_t samp_freq;
54  uint32_t byte_rate;
55  uint16_t block_align;
56  uint16_t bit_samp;
57  uint8_t data_flag[4];
58  uint32_t length;
59 } wave_header_t;
60 
63 typedef struct wave_file
64 {
65  wave_header_t header;
66  uint32_t *pData;
67 } wave_file_t;
68 
69 /*******************************************************************************
70  * Prototypes
71  ******************************************************************************/
73 typedef uint32_t (*APP_GET_DATA_FUNC)(uint32_t NumBytesReq, uint8_t **ppDada, uint32_t offset);
75 int PLAYSOUND_GetWaveFileInfo(uint8_t* pBuffer, wave_file_t *pWave);
76 int PLAYSOUND_Play(APP_GET_DATA_FUNC fpAppGetData);
77 void PLAYSOUND_Init(void);
78 
79 #endif
80 
81 /*******************************************************************************
82  * EOF
83  ******************************************************************************/
uint32_t samp_freq
Definition: playsound.h:53
uint16_t bit_samp
Definition: playsound.h:56
void PLAYSOUND_Init(void)
Init sound card.
Definition: playsound.c:89
uint32_t * pData
data pointer
Definition: playsound.h:66
uint32_t byte_rate
Definition: playsound.h:54
uint16_t block_align
Definition: playsound.h:55
int PLAYSOUND_Play(APP_GET_DATA_FUNC fpAppGetData)
Use sound card to play audio, need wave file data, only support standard Windows PCM uncompressed fil...
Definition: playsound.c:116
int PLAYSOUND_GetWaveFileInfo(uint8_t *pBuffer, wave_file_t *pWave)
Decode wave file header, only support standard Windows PCM uncompressed file.
Definition: playsound.c:199
uint32_t(* APP_GET_DATA_FUNC)(uint32_t NumBytesReq, uint8_t **ppDada, uint32_t offset)
&lt;
Definition: playsound.h:73
Definition: modulator.h:70
Definition: modulator.h:88
uint32_t fmt_len
Definition: playsound.h:50